package com.example.tabbar.fragment

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.tabbar.adapter.AuditAdapter
import com.example.tabbar.databinding.FragmentAuditBinding
import com.example.tabbar.room.entity.SamplingData
import com.example.tabbar.utils.CustomLine


class AuditFragment : Fragment() {
    private var binding : FragmentAuditBinding? = null
    private var recyclerView: RecyclerView? = null
    private var adapter: AuditAdapter? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        arguments?.let {

        }
    }

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = FragmentAuditBinding.inflate(inflater,container,false)
        return binding?.root
    }
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        recyclerView = binding?.auditList
        adapter = AuditAdapter()
        recyclerView?.adapter = adapter
        recyclerView?.layoutManager  = LinearLayoutManager(requireContext())

        // 创建自定义分割线
        CustomLine(requireContext(), recyclerView!!)

        adapter?.setItems(listOf(SamplingData(id = 1, result = false), SamplingData(id = 2, result = false), SamplingData(id = 3, result = true)))
    }

    companion object {

        @JvmStatic
        fun newInstance() =
            AuditFragment().apply {
                arguments = Bundle().apply {

                }
            }
    }
}